package zhixin.Utils;

import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorConvertOp;

/**
 * @program: demo01
 * @description:
 * @author: 致心
 * @create: 2020-08-28 12:51
 **/
public class ImgToWord {

    public static BufferedImage grayImage(BufferedImage img) {
        int srcH = img.getHeight();
        int srcW = img.getWidth();
        BufferedImage bufferedImage = new BufferedImage(srcW, srcH,BufferedImage.TYPE_3BYTE_BGR);
        bufferedImage.getGraphics().drawImage(img, 0,0, srcW, srcH, null);
        bufferedImage=new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY),null).filter (bufferedImage,null);
        return bufferedImage;
    }

}
